#include "stdio.h"
#include "string"

#pragma pack(1)
struct connInfo{
	int fd;
	char ip[20];
	void *ptr;
	connInfo(){
		fd = -1;
		memcpy(ip, 0, 20);
		ptr = NULL;
	}
};
#pragma pack()

extern "C"{

	int handle_open(int fd){
		printf("handle_open fd:%d\n", fd);
		return 0;
	}

	int handle_input(int fd, char *buf, int len, connInfo *info){
		if( len < 5 ){
			return 0;
		}
		char data[6] = {0};
		memcpy(data, buf, 5);
		int ret = 5;
		printf("fd:%d, ip:%s, data:%s, len:%d\n", info->fd, info->ip, data, ret);
		info->ptr = (void *)ret;
		return ret;
	}

	int handle_close(int fd){
		printf("handle_close fd:%d\n", fd);
		return 0;
	}
}
